<p><table border=1 bordercolor=#808080 cellspacing=0 cellpadding=2 style="margin-left:1.4pt;border-collapse:collapse;border:1">
<tr bgcolor=#e0e0e0 align=center><td width="24%">姓名 Name</td><td width="40%">報名資料 Info</td>
  <td width="12%"><font size="2">午餐 (L)unch</font><br>
    <font size="2">晚餐 (D)inner<br>
    L&nbsp;&nbsp;&nbsp;D</font></td>
  <td><font size="2">Sessions</font><br>
    <font size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;早&nbsp;&nbsp;中&nbsp;&nbsp;晚</font></td>
  <td>Action</td>
</tr>

<?php
$dbConn = new mysqli(HOST,USER,PWD,DB);
$dbConn->query("SET NAMES 'utf8'");
$rid=  $_SESSION['rid'];
$expire = $_SESSION['expire'];

/* prepare statement */

if ($stmt = $dbConn->prepare("select b.reginfoid, b.cname, b.first_name, b.last_name, b.relationship, b.gender, b.groups, b.pastoral_staff, b.special_need, b.meal1, b.meal2, b.meal3, b.meal4, b.meal5, b.meal6, b.meal7, b.meal8, b.session1, b.session2, b.session3, b.session4, b.session5, b.session6, b.session7, b.session8, b.session9, b.session10, b.session11 from registration a, registration_info b where a.rid= ?  and a.rid = b.rid ")) {
    $stmt->bind_param('i', $rid);
    $stmt->execute(); 
    $stmt->bind_result($col1,$col2,$col3,$col4,$col5,$col6,$col7,$col8,$col9,$meal1,$meal2,$meal3,$meal4,$meal5,$meal6,$meal7,$meal8, $ses1, $ses2, $ses3, $ses4, $ses5, $ses6, $ses7, $ses8, $ses9, $ses10, $ses11);
    $i = 0;
    while ($stmt->fetch()) {
	echo "<form name=f"; printf("%d ",i); echo "action=con_modreginfo.php method=POST>";
	echo "<input type=hidden name=rid value=" . $rid . ">";
	echo "<input type=hidden name=reginfoid value=" . $col1 . ">";
	echo "<tr><td width=22% align=left><font size=\"2\">姓名:</font><input type=text name=cname size=8 value=" . $col2 . ">";
	echo "<br><font size=\"2\" color=#FF0000>英文名First:</font><input type=text name=first_name size=10 maxlength=20 value=" . $col3 . ">";
	echo "<br><font size=\"2\" color=#FF0000>英文姓Last:</font><input type=text name=last_name size=10 maxlength=20 value=" . $col4 . ">";
	echo "</td><td align=right><font size=\"2\">關係Relation:</font>";
	$sel = $col5;
	include("con_sel_relation.php");
	echo "<br><font size=\"2\">性別Gender:</font>";
	$sel = $col6;
	include("con_sel_gender.php");
	echo "<br><font size=\"2\">組別Group:</font>";
	$sel = $col7;
	include("con_sel_group.php");
	echo "<br><font size=\"2\">特別需要Special Needs:</font>";
	$sel = $col9;
	include("con_sel_special.php");
	$sel= $col8;
    if ($sel <> 'N') {
	echo "<br><font size=\"2\">牧者 Minister:</font>";
	include("con_sel_pastor.php");
	}
	//if ($col8) $check="checked "; else $check = "";
	//echo "<br>Fulltime Minister:<input type=checkbox " . $check . "name=pastor value=1>";
	echo "</td><td><table border=0 cellspacing=0 cellpadding=0>";
	if ($meal1) $check="checked "; else $check = "";
	echo "<tr><td>&nbsp;7/2</td><td></td><td><input type=checkbox " . $check . "name=meal1 value=1></td></tr>";
	if ($meal2) $check="checked "; else $check = "";
	echo "<tr><td>&nbsp;7/3</td><td><input type=checkbox " . $check . "name=meal2 value=1>";
	if ($meal3) $check="checked "; else $check = "";
	echo "</td><td><input type=checkbox " . $check . "name=meal3 value=1></td></tr>";
	if ($meal4) $check="checked "; else $check = "";
	echo "<tr><td>&nbsp;7/4</td><td><input type=checkbox " . $check . "name=meal4 value=1>";
	if ($meal5) $check="checked "; else $check = "";
	echo "</td><td><input type=checkbox " . $check . "name=meal5 value=1></td></tr>";
	if ($meal6) $check="checked "; else $check = "";
	echo "<tr><td>&nbsp;7/5</td><td><input type=checkbox " . $check . "name=meal6 value=1>";
	if ($meal7) $check="checked "; else $check = "";
	echo "</td><td><input type=checkbox " . $check . "name=meal7 value=1></td></tr>";
	if ($meal8) $check="checked "; else $check = "";
	echo "<tr><td>&nbsp;7/6</td><td><input type=checkbox " . $check . "name=meal8 value=1></td></tr></table>";

	echo "</td><td><table border=0 cellspacing=0 cellpadding=0>";
	if ($ses1) $check="checked "; else $check = "";
	echo "<tr><td>7/2</td><td></td><td></td><td><input type=checkbox " . $check . "name=ses1 value=1></td></tr>";
	if ($ses2) $check="checked "; else $check = "";
	echo "<tr><td>7/3</td><td><input type=checkbox " . $check . "name=ses2 value=1>";
	if ($ses3) $check="checked "; else $check = "";
	echo "</td><td><input type=checkbox " . $check . "name=ses3 value=1></td>";
	if ($ses4) $check="checked "; else $check = "";
	echo "</td><td><input type=checkbox " . $check . "name=ses4 value=1></td></tr>";
	if ($ses5) $check="checked "; else $check = "";
	echo "<tr><td>7/4</td><td><input type=checkbox " . $check . "name=ses5 value=1>";
	if ($ses6) $check="checked "; else $check = "";
	echo "</td><td><input type=checkbox " . $check . "name=ses6 value=1></td>";
	if ($ses7) $check="checked "; else $check = "";
	echo "</td><td><input type=checkbox " . $check . "name=ses7 value=1></td></tr>";
	if ($ses8) $check="checked "; else $check = "";
	echo "<tr><td>7/5</td><td><input type=checkbox " . $check . "name=ses8 value=1>";
	if ($ses9) $check="checked "; else $check = "";
	echo "</td><td><input type=checkbox " . $check . "name=ses9 value=1></td>";
	if ($ses10) $check="checked "; else $check = "";
	echo "</td><td><input type=checkbox " . $check . "name=ses10 value=1></td></tr>";
	if ($ses11) $check="checked "; else $check = "";
	echo "<tr><td>7/6</td><td><input type=checkbox " . $check . "name=ses11 value=1></td></tr></table>";
    if ($expire >= 0 ) {
    if ($_SESSION['foreign'] == "Y") {
	echo "</td><td><input type=submit name=action value=\"簽證信函 Visa\" >";
	echo "<br>";
	echo "<input type=submit name=action value=\"修改 Update\">";
	echo "<br><br>";
	echo " <input type=submit name=action value=\"刪除 Delete\">";
	} else {
	echo "</td><td><input type=submit name=action value=\"修改 Update\">";
	echo "<br><br>";
	echo " <input type=submit name=action value=\"刪除 Delete\">";
	}
	} else { echo "</td><td>&nbsp;";
	}
	echo "</td></tr></form>";
	$i++;
    }
    echo "<form name=fadd action=con_modreginfo.php method=POST>";
    echo "<tr><td align=left><font size=\"2\">姓名:</font><input type=text name=cname size=8>";
    echo "<br><font size=\"2\" color=#FF0000>英文名First:<input type=text name=first_name size=10 maxlength=20>";
    echo "<br><font size=\"2\" color=#FF0000>英文姓Last:</font><input type=text name=last_name size=10 maxlength=20>";
    echo "</td><td align=right><font size=\"2\">關係 Relation:</font>";
    include("con_sel_relation.php");
    echo "<br><font size=\"2\">性別 Gender:</font>";
    include("con_sel_gender.php");
    echo "<br><font size=\"2\">組別 Group:</font>";
    include("con_sel_group.php");
    echo "<br><font size=\"2\">特別需要 Special Needs:</font>";
    $sel = 0;
    include("con_sel_special.php");
   // echo "<br>Fulltime Minister:<input type=checkbox name=pastor value=1>";
    echo "</td><td><table border=0 cellspacing=0 cellpadding=0>";
    echo "<tr><td>7/2</td><td></td><td><input type=checkbox name=meal1 value=1></td></tr>";
    echo "<tr><td>7/3</td><td><input type=checkbox name=meal2 value=1>";
    echo "</td><td><input type=checkbox name=meal3 value=1></td></tr>";
    echo "<tr><td>7/4</td><td><input type=checkbox name=meal4 value=1>";
    echo "</td><td><input type=checkbox name=meal5 value=1></td></tr>";
    echo "<tr><td>7/5</td><td><input type=checkbox name=meal6 value=1>";
    echo "</td><td><input type=checkbox name=meal7 value=1></td></tr>";
    echo "<tr><td>7/6</td><td><input type=checkbox name=meal8 value=1></td></tr></table>";

    echo "</td><td><table border=0 cellspacing=0 cellpadding=0>";
    echo "<tr><td>7/2</td><td></td><td></td><td><input type=checkbox name=ses1 value=1></td></tr>";
    echo "<tr><td>7/3</td><td><input type=checkbox name=ses2 value=1>";
    echo "</td><td><input type=checkbox name=ses3 value=1></td>";
    echo "</td><td><input type=checkbox name=ses4 value=1></td></tr>";
    echo "<tr><td>7/4</td><td><input type=checkbox name=ses5 value=1>";
    echo "</td><td><input type=checkbox name=ses6 value=1></td>";
    echo "</td><td><input type=checkbox name=ses7 value=1></td></tr>";
    echo "<tr><td>7/5</td><td><input type=checkbox name=ses8 value=1>";
    echo "</td><td><input type=checkbox name=ses9 value=1></td>";
    echo "</td><td><input type=checkbox name=ses10 value=1></td></tr>";
    echo "<tr><td>7/6</td><td><input type=checkbox name=ses11 value=1></td></tr></table>";

    echo "</td><td><form action=con_modreginfo.php method=post>";
    echo "<input type=hidden name=rid value=" . $rid . ">";
	if ($expire >= 0 ) {
    echo "<input type=submit name=action value=\"增加 Add\">";
	} 
    echo "</td></tr>";
    echo "</table></p>";
}

$action =$_SESSION['last_action'];
$survey=$_SESSION['survey'];
$_SESSION['survey']='N';
if ( ($action == '刪除 Delete') and ($survey == 'Y') ) {
echo "是否可以知道您為甚麼刪除報名資料呢？May we know the reason you have deleted the registration?<br>";
echo "<table>";
echo "<tr><td width=\"10%\"><input type=\"radio\" name=\"comment\" value=\"簽證 Visa\">簽證 Visa</td>";
echo "<td width=\"20%\"><input type=\"radio\" name=\"comment\" value=\"室友 Roommate\">室友 Roommate</td></tr>";
echo "<tr><td><input type=\"radio\" name=\"comment\" value=\"旅館 Hotel\">旅館 Hotel</td>";
echo "<td><input type=\"radio\" name=\"comment\" value=\"機票 Airfare\"> 機票 Airfare</td></tr>";
echo "<tr><td><input type=\"radio\" name=\"comment\" value=\"經濟 Financial Situation\">經濟 Financial Situation<br>";
echo "<td><input type=\"radio\" name=\"comment\" value=\"身體健康 Health\">身體健康 Health</td></tr>";
echo "<tr><td><input type=\"radio\" name=\"comment\" value=\"工作需要 Job \">工作需要 Job</td>";
echo "<td><input type=\"radio\" name=\"comment\" value=\"其他 Other\">其他 Other</td></tr>";
echo "<tr><td><input type=submit name=action value='意見 Comment'</td>";
echo "</tr></table></form>";
}
?>
